import request from '@/utils/request.js' // 导入axios副本
// axios.defaults.baseURL = 'http://192.168.17.78:8008/'
// axios.defaults.baseURL = 'http://geek.itheima.net/'
// axios.defaults.baseURL = process.env.VUE_APP_URL

// 登录
export function authorizationsPost (data) {
  return request({
    url: '/v1_0/authorizations',
    method: 'post',
    // 左边data是固定的， axios的属性
    data: data
  })
}

// 获取用户信息
export function userProfile () {
  return request({
    url: '/v1_0/user/profile'
  })
}

// 获取频道列表
export function channels () {
  return request({
    url: '/v1_0/channels'
  })
}

// 获取文章列表
export function mpArticles (params) {
  return request({
    url: '/v1_0/mp/articles',
    params
  })
}

// 删除文章
export function delArticles (id) {
  return request({
    url: '/v1_0/mp/articles/' + id,
    method: 'delete'
  })
}

// 发布文章
export function createArticles (form, draft) {
  console.log('form:', form)
  return request({
    url: '/v1_0/mp/articles',
    method: 'post',
    data: form,
    params: {
      draft: draft
    }
  })
}

// 获取文章详情
export function mpArticlesGet (id) {
  return request({
    url: '/v1_0/mp/articles/' + id
  })
}

export function apArticlesPut(data,draft){
  return request({
    url:'/v1_0/mp/articles/'+data.id,
    method:'put',
    params:{
      draft
    },
    data 
  })
}
